package com.hr.rbac.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hr.rbac.dao.Impl.RoleDaoImpl;

public class ValidateRoleName extends HttpServlet {
	
	private RoleDaoImpl roleDaoImpl = new RoleDaoImpl();
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		
		String role_Name = request.getParameter("rolename");
		if(roleDaoImpl.findByRoleName(role_Name).getRole_ID()!=null){
			response.getWriter().print("1");
		}else if(role_Name.equalsIgnoreCase("") ){
			response.getWriter().print("2");
		}else{
			response.getWriter().print("3");
		}
	}

}
